package com.ag.zhh.vo;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.ag.bean.TbDeptType;

/**
 * Dept VO. 部门VO valueObjct
 * 
 * @author 张颢铧
 */
@Entity
@Table(name = "TB_DEPT", schema = "dbo")
public class Dept implements java.io.Serializable {

	// Fields
	// 通讯录中用到的字段starts
	private String DId;
	private Dept Dept;
	private String DName;
	//private TbDeptType tbDeptType;
	private Integer DIf; // 是否应急部门标志位
	private String DAddress;
	private String DLogoUrl;
	private String DLati;
	private String DLng;
	private Set<Contact> Contacts = new HashSet<Contact>(0);

	// ends

	// Constructors



	public Dept(String id, Dept dept, String name,
			Integer if1, String address, String logoUrl, String lati,
			String lng, Set<Contact> contacts) {
		super();
		DId = id;
		Dept = dept;
		DName = name;
		
		DIf = if1;
		DAddress = address;
		DLogoUrl = logoUrl;
		DLati = lati;
		DLng = lng;
		Contacts = contacts;
	}

	/** default constructor */
	public Dept() {
	}

	/** minimal constructor */
	public Dept(String DId) {
		this.DId = DId;
	}

	// Property accessors
	@Id
	@Column(name = "D_ID", unique = true, nullable = false, length = 16)
	public String getDId() {
		return this.DId;
	}

	public void setDId(String DId) {
		this.DId = DId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "D_FID")
	public Dept getDept() {
		return this.Dept;
	}

	public void setDept(Dept Dept) {
		this.Dept = Dept;
	}

	@Column(name = "D_LATI", length = 20)
	public String getDLati() {
		return this.DLati;
	}

	public void setDLati(String DLati) {
		this.DLati = DLati;
	}

	@Column(name = "D_LNG", length = 20)
	public String getDLng() {
		return this.DLng;
	}

	public void setDLng(String DLng) {
		this.DLng = DLng;
	}

	@Column(name = "D_NAME", length = 50, nullable = false, unique = true)
	public String getDName() {
		return this.DName;
	}

	public void setDName(String DName) {
		this.DName = DName;
	}

//	@ManyToOne(fetch = FetchType.EAGER)
//	@JoinColumn(name = "D_TYPE")
//	public TbDeptType getTbDeptType() {
//		return this.tbDeptType;
//	}
//
//	public void setTbDeptType(TbDeptType tbDeptType) {
//		this.tbDeptType = tbDeptType;
//	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinTable(name = "TB_DEPT_AND_CONTACT", schema = "SCOTT", joinColumns = { @JoinColumn(name = "D_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "C_ID", nullable = false, updatable = false) })
		public Set<Contact> getContacts() {
		return Contacts;
	}

	public void setContacts(Set<Contact> contacts) {
		Contacts = contacts;
	}

	@Column(name = "D_IF", nullable = true)
	public Integer getDIf() {
		return DIf;
	}

	public void setDIf(Integer if1) {
		DIf = if1;
	}

	@Column(name = "D_ADDRESS", length = 100)
	public String getDAddress() {
		return DAddress;
	}

	public void setDAddress(String address) {
		DAddress = address;
	}

	@Column(name = "D_LOGO_URL", length = 100)
	public String getDLogoUrl() {
		return DLogoUrl;
	}

	public void setDLogoUrl(String logoUrl) {
		DLogoUrl = logoUrl;
	}



	// @Column(name = "D_TYPE", length = 20)
	// public String getDType() {
	// return this.DType;
	// }
	//
	// public void setDType(String DType) {
	// this.DType = DType;
	// }
}
